package niuke.week4;

import java.math.BigInteger;
import java.util.Random;
import java.util.Scanner;
import java.util.TreeMap;

/**
 * @title: MaxSunOfYiHuoTrie
 * @Author jianglei
 * @Date: 2021/12/3 16:43
 * @Version 1.0
 */

public class MaxSunOfYiHuoTrie {
   static  Tire tire = new Tire();
    public  static String toBin(int a){
        if(a<0)
            return Integer.toBinaryString(a);
        else {
            String s = Integer.toBinaryString(a);
            int numerZero = 32-s.length();
            String str ="";
            for (int i = 0; i < numerZero; i++) {
                str+="0";
            }
            return str+s;
        }
    }

    public  static String getOver(String str){//数字位取反
        int num = Integer.parseInt(str,2);
        return toBin(~num).substring(1);
    }

    public static void main(String[] args) {
//        System.out.println(Integer.toBinaryString(8));
//        BigInteger bi = new BigInteger("1000", 2);
//        System.out.println(bi.intValue());
//        System.out.println(new StringBuilder("0001").replace(2,3,"*"));
        sol();
//        Random r = new Random();
//        System.out.println(100);
//        for (int i = 0; i < 1000; i++) {
//            System.out.println(r.nextInt(100000)-500);
//        }
    }


    public static void  sol(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();;
        }
        System.out.println(maxXorSubarray(arr));
    }

    public static int maxXorSubarray(int [] arr){
        if (arr == null || arr.length == 0)
            return 0;
        int max = Integer.MIN_VALUE;
        int eor = 0; // 0..i 异或和
        tire.add(toBin(0));
        for (int i = 0; i < arr.length; i++) {
            eor ^= arr[i];//前i个异或和
            tire.add(toBin(eor));
            max = Math.max(max,maxXor(eor));//求取每一种异或情况
        }
        return max;
    }
    // 给定一个eorj，eorj表示eor[j]，即以j位置结尾的情况下，arr[0..j]的异或和
    // 因为之前把eor[0]、eor[1]...eor[j-1]都加入过这棵前缀树，所以可以选择出一条最优路径来
    // maxXor方法就是把最优路径找到，并且返回eor[j]与最优路径结合之后得到的最大异或和
    public static  int maxXor(int  eori) {//【1.。。5】 ^[1.2]   [1,3]   [1,4]
        String s = toBin(eori);//装换为2进制
        String expect = getExpect(s);//使得该二进制最大的值 匹配结果 符号位必须是0，其余的尽量为1
        for (int i = 1; i < expect.length(); i++) {//从头到尾进行匹配
            String substring = expect.substring(0, i);//[0...i)
            if(!tire.prefix(substring)){//0001]100  //匹配失败，就把这一位替换了
                if(substring.charAt(i-1)=='0')//把这一位替换成1
                    expect =  new StringBuilder(expect).replace(i-1,i,"1").toString();
                else
                    expect =  new StringBuilder(expect).replace(i-1,i,"0").toString();
            }
        }
        int expectInt = new BigInteger(expect, 2).intValue();
        return eori^expectInt;
    }

    public  static String getExpect(String eori){
        String expect = eori.charAt(0)=='0'?"0":"1";//符号位一致
        String numberBin = getOver(eori.substring(1));//数字位取反
        return expect+numberBin;
    }
}


class Tire {
    private TrieNode root;
    private int size;

    Tire() {
        root = new TrieNode();
        size = 0;
    }

    // 添加
    public void add(String word) {
        TrieNode cur = root;
        for (int i = 0; i < word.length(); i++) {
            char c = word.charAt(i);
            if (cur.next.get(c) == null)//如果当前字母不存在则插入当前字母
                cur.next.put(c, new TrieNode());
            cur = cur.next.get(c);//当前的node总是指向当前字母所在的node
        }
        if (!cur.isword)
            size++;
        cur.isword = true;
    }

    // 是否存在某單詞
    public boolean contains(String word) {
        TrieNode cur = root;
        for (int i = 0; i < word.length(); i++) {
            char c = word.charAt(i);
            if (!cur.next.containsKey(c))
                return false;
            cur = cur.next.get(c);
        }
        return cur.isword;
    }
    // 查询是否包含，.代表任意字母
    public boolean pointToContaints(String word) {
        return match(root, word, 0);
    }

    private boolean match(TrieNode node, String word, int index) {
        if (index == word.length()) {//递归结束条件
            return node.isword;
        }
        char c = word.charAt(index);
        if (c != '.') {//当前字符不为点
            if (node.next.get(c) == null)
                return false;
            return match(node.next.get(c), word, index + 1);
        } else {//当前字符为点
            for (char nextChar : node.next.keySet())
                if (match(node.next.get(nextChar), word, index + 1))//匹配下一个节点
                    return true;
            return false;
        }
    }

    // 前缀
    public boolean prefix(String prefix) {
        TrieNode cur = root;
        for (int i = 0; i < prefix.length(); i++) {
            char c = prefix.charAt(i);
            if (!cur.next.containsKey(c))
                return false;
            cur = cur.next.get(c);
        }
        return true;
    }



}

class TrieNode {
    boolean isword;
    int val;
    TreeMap<Character,TrieNode> next;


    TrieNode(boolean isword){
        this.isword = isword;
        next = new TreeMap<Character,TrieNode>();
    }
    TrieNode(){
        this(false);
    }
    TrieNode(int val){
        this.val = val;
    }
}